// this is the townscript for town 13: Tel-dakrach

begintownscript;

variables;

int choice,i,f;

body;

beginstate INIT_STATE;
	set_crime_tolerance(3);

	set_name(37,"Dakrach's spirit");
	
	if (get_flag(200,0) == 1) {
			set_terrain(13,11,137);
			set_terrain(13,12,138);
			set_terrain(13,29,137);
			set_terrain(13,30,138);
			}
	if (get_flag(13,13) > 0)
			activate_hidden_group(4);		
	if (get_flag(13,5) > 0 )
			flip_terrain(6,3);
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;

	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(37,"Come to me for information");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(37,"You have to do the ceremony");
		
	if (get_flag(13,15) == 1) // Book will not appear on pedestal anymore if cutscene run
			set_terrain(12,41,218);	
	
break;

beginstate 10;
if (get_flag(13,2) > 0)
		end();
	message_dialog("On these two tables, two sceptres are lying. They are identical. When you try to take the left one however, a big wave of energy throws your hand back. The right does nothing.","");
	set_state_continue(11);
break;

beginstate 11;
reset_dialog();
add_dialog_str(0,"You could try to take them, as one of these sceptres probably is the one Benthol wants you to bring for him. Do you take them?",0);
add_dialog_choice(0,"Leave them.");
add_dialog_choice(1,"Take them.");
choice = run_dialog(0);
	
	if (choice == 2) {
			change_spec_item(3,1);
			change_spec_item(4,1);
			set_flag(13,13,1);
			set_flag(13,2,1);
			set_state_continue(12);
			}
break;

beginstate 12;
reset_dialog();
add_dialog_str(0,"Now that you did take them, which do you wish to give to Benthol? The real one looks really powerful. Maybe he wouldn't notice the difference between the real and the false one.",0);
add_dialog_choice(0,"The real sceptre.");
add_dialog_choice(1,"The fake sceptre.");
choice = run_dialog(0);

	if (choice == 1) {
			set_flag(13,0,1);
			set_flag(13,10,1);
			}
			
	if (choice == 2) {
			message_dialog("You pocket the sceptres. You put the real sceptre down in your backpack, while you put the false one on top. by doing this, you feel as if a new power settles in you. You feel stronger.","");
			award_party_xp(100,20);
			set_flag(13,1,1);
			set_flag(13,10,1);
			}
break;

beginstate 13;
if (get_flag(13,15) == 1)
		set_state_continue(14);
	reset_dialog();
	add_dialog_str(0,"In the dark, you see a book. Reading it here will be quite difficult, Maybe you want to take it out to the hallway, where there is light?",0);
	add_dialog_choice(0,"Take the book to light.");
	add_dialog_choice(1,"Leave it.");
	choice = run_dialog(0);
	
	if (choice == 1)
			set_state_continue(15);
break;

beginstate 14;
	message_dialog("The once powerful book is now totally worthless to you","");
break;

beginstate 15;
		reset_dialog();
		add_dialog_str(0,"You take the book off the pedestal. Nothing happens.",0);
		add_dialog_choice(0,"Okay.");
		choice = run_dialog(0);
		
		set_flag(13,15,1);
		set_state_continue(21);
break;

beginstate 16;
if (get_flag(13,13) == 1) {
		message_dialog("Before you can reach the door, a shade appears in front of you.","_I'm the shade of the warrior Sir Dakrach. You stole my sceptres! You shall have to do the ceremony in order to get out, or I'll curse you forever! Come to my tomb for more information._ The shade disappears.");
		activate_hidden_group(4);
		set_flag(13,13,2);
		}
break;

beginstate 17;
if (get_flag(13,2) == 1) {
		if (get_flag(13,5) != 2) {
				if (get_flag(13,14) == 0) {
						message_dialog("When you are about to leave the crypt, the shade appears once more in front of you. _I warned you for this!_ He looks angry. Then he disappears. You start to feel ill, very ill. The feeling slowly fades away.","After the feeling has totally passed, you look at your arms to see what happened. A small black spot has appeared on your shoulder. Dread curse...");
						change_char_health(0,-100);
						change_char_health(1,-100);
						change_char_health(2,-100);
						change_char_health(3,-100);
						change_char_health(4,-100);
						change_char_health(5,-100);
				
						change_char_energy(0,-50);
						change_char_energy(1,-50);
						change_char_energy(2,-50);
						change_char_energy(3,-50);
						change_char_energy(4,-50);
						change_char_energy(5,-50);
				
						change_char_xp(0,-10000);
						change_char_xp(1,-10000);
						change_char_xp(2,-10000);
						change_char_xp(3,-10000);
						change_char_xp(4,-10000);
						change_char_xp(5,-10000);
						
						// Dread curse enabled
						
						alter_stat(1000,31,2);
						
						set_flag(275,2,1);
						set_flag(13,14,1);
						}
				}
		}
break;

beginstate 18;
if (get_flag(13,6) == 1)
		end();
	message_dialog("This is one of the many burials in Tel Dakrach. In the dark, you see about nine sarcophagi. You also see about six things walking around.","");
	set_flag(13,6,1);
break;

beginstate 19;
if (get_flag(13,7) == 1)
		end();
	message_dialog("This passage is fully lit and has a paved floor. You gather this passage probably leads to some sort of important place.","");
	set_flag(13,7,1);
break;

beginstate 20;
	move_to_new_town(14,5,41);
break;

beginstate 21;

// beginning cutscene

	i = 86;
	while (char_ok(i)) {
		i = i + 1;
		}
		
		text_bubble_on_char(0,"Lets take the book to light.");
		force_instant_terrain_redraw();
		pause(20);

		set_terrain(12,41,218);

// walking to light

		text_bubble_on_char(0,"");
		march_party(11,42);
		force_view_center(11,42);
		force_instant_terrain_redraw();
		pause(5);

		march_party(11,43);
		force_view_center(11,43);
		force_instant_terrain_redraw();
		pause(5);

		march_party(11,44);
		force_view_center(11,44);
		force_instant_terrain_redraw();
		pause(5);

		march_party(10,44);
		force_view_center(10,44);
		force_instant_terrain_redraw();
		pause(5);

		march_party(10,43);
		force_view_center(10,43);
		force_instant_terrain_redraw();
		pause(5);

		march_party(10,42);
		force_view_center(10,42);
		force_instant_terrain_redraw();
		pause(5);

		march_party(10,41);
		force_view_center(10,41);
		force_instant_terrain_redraw();
		pause(5);
		
		march_party(10,40);
		force_view_center(10,40);
		force_instant_terrain_redraw();
		pause(5);

// opening book

		text_bubble_on_char(3,"Now we can see");
		force_instant_terrain_redraw();
		pause(20);

		text_bubble_on_char(3,"");
		text_bubble_on_char(3,"what's written in it");
		force_instant_terrain_redraw();
		pause(20);

		text_bubble_on_char(3,"");
		text_bubble_on_char(0,"Let's see");
		force_instant_terrain_redraw();
		pause(20);

		text_bubble_on_char(0,"");
		force_instant_terrain_redraw();
		message_dialog("You slowly start to read the book. Its beautifully made. The letters are probably hand written. You soon figure out this book contains an enchantment. You begin to speak louder and louder...","");

		text_bubble_on_char(0,"In maritus tu non alis!");
		force_instant_terrain_redraw();
		pause(20);

		text_bubble_on_char(0,"");
		text_bubble_on_char(2,"Could you speak softer?");
		force_instant_terrain_redraw();
		pause(20);

		text_bubble_on_char(2,"");
		text_bubble_on_char(0,"Quod moriebaris");
		force_instant_terrain_redraw();
		pause(20);

		text_bubble_on_char(0,"");
		text_bubble_on_char(3,"Please! speak softer!");
		force_instant_terrain_redraw();
		pause(20);

		text_bubble_on_char(3,"");
		text_bubble_on_char(0,"si hoc clamabis!");
		force_instant_terrain_redraw();
		pause(20);

		text_bubble_on_char(0,"");
		text_bubble_on_char(0,"Hmmm");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(0,"");
		text_bubble_on_char(0,"Does anybody know");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(0,"");
		text_bubble_on_char(0,"what that meant?");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(0,"");
		text_bubble_on_char(1,"No");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(1,"");
		text_bubble_on_char(2,"Sorry");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(2,"");
		text_bubble_on_char(3,"It means");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(3,"");
		text_bubble_on_char(3,"You wouldn't marry");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(3,"");
		text_bubble_on_char(3,"because you will die");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(3,"");
		text_bubble_on_char(3,"if you");
		force_instant_terrain_redraw();
		pause(12);

		text_bubble_on_char(3,"");
		text_bubble_on_char(3,"shouted this");
		force_instant_terrain_redraw();
		pause(40);

		text_bubble_on_char(3,"");
		text_bubble_on_char(1,"Fool! Now you've done it!");
		force_instant_terrain_redraw();
		pause(20);

		text_bubble_on_char(1,"");
		text_bubble_on_char(0,"Sorry, I didn't know");
		force_instant_terrain_redraw();
		pause(20);

		text_bubble_on_char(0,"");
		text_bubble_on_char(0,"What the...!");
		force_instant_terrain_redraw();
		pause(20);

// monsters appearing

		if (char_ok(86) == 0) {
				i = 86;
				set_state_continue(25);
				}
		if (char_ok(87) == 0) {
				i = 87;
				set_state_continue(25);
				}
		if (char_ok(88) == 0) {
				i = 88;
				set_state_continue(25);
				}
		if (char_ok(89) == 0) {
				i = 89;
				set_state_continue(25);
				}
		if (char_ok(90) == 0) {
				i = 90;
				set_state_continue(25);
				}
		if (char_ok(91) == 0) {
				i = 91;
				set_state_continue(25);
				}
		if (char_ok(92) == 0) {
				i = 92;
				set_state_continue(25);
				}
		if (char_ok(93) == 0) {
				i = 93;
				set_state_continue(25);
				}
		if (char_ok(94) == 0) {
				i = 94;
				set_state_continue(25);
				}
		if (char_ok(95) == 0) {
				i = 95;
				set_state_continue(25);
				}
		if (char_ok(96) == 0) {
				i = 96;
				set_state_continue(25);
				}
		if (char_ok(97) == 0) {
				i = 97;
				set_state_continue(25);
				}
		if (char_ok(98) == 0) {
				i = 98;
				set_state_continue(25);
				}
		if (char_ok(99) == 0) {
				i = 99;
				set_state_continue(25);
				}
		if (char_ok(100) == 0) {
				i = 100;
				set_state_continue(25);
				}
		if (char_ok(101) == 0) {
				i = 101;
				set_state_continue(25);
				}
		if (char_ok(102) == 0) {
				i = 102;
				set_state_continue(25);
				}
		if (char_ok(103) == 0) {
				i = 103;
				set_state_continue(25);
				}
		if (char_ok(104) == 0) {
				i = 104;
				set_state_continue(25);
				}
		if (char_ok(105) == 0) {
				i = 105;
				set_state_continue(25);
				}
		if (char_ok(106) == 0) {
				i = 106;
				set_state_continue(25);
				}
		if (char_ok(107) == 0) {
				i = 107;
				set_state_continue(25);
				}
		if (char_ok(108) == 0) {
				i = 108;
				set_state_continue(25);
				}
		if (char_ok(109) == 0) {
				i = 109;
				set_state_continue(25);
				}
		if (char_ok(110) == 0) {
				i = 110;
				set_state_continue(25);
				}
		if (char_ok(111) == 0) {
				i = 111;
				set_state_continue(25);
				}
		if (char_ok(112) == 0) {
				i = 112;
				set_state_continue(25);
				}
		if (char_ok(113) == 0) {
				i = 113;
				set_state_continue(25);
				}
		if (char_ok(114) == 0) {
				i = 114;
				set_state_continue(25);
				}
		if (char_ok(115) == 0) {
				i = 115;
				set_state_continue(25);
				}
		if (char_ok(116) == 0) {
				i = 116;
				set_state_continue(25);
				}
break;

beginstate 22;
if (get_flag(13,17) == 0) {
reset_dialog();
add_dialog_str(0,"This altar seems to be very old. Its probably standing here since this crypt was made. A certain force, however weak, pulls you down. Do you give in and kneel?",0);
add_dialog_choice(0,"Kneel");
add_dialog_choice(1,"Leave");
choice = run_dialog(0);
		
	if (choice == 1) {
		message_dialog("You kneel down in front of the big, black altar. Smoke is beginning to appear on the other side of the altar. As the power lets you loose, so you can stand up again, a big demonic creature arises.","");
				
		if (char_ok(86) == 0) {
				i = 86;
				set_state_continue(26);
				}
		if (char_ok(87) == 0) {
				i = 87;
				set_state_continue(26);
				}
		if (char_ok(88) == 0) {
				i = 88;
				set_state_continue(26);
				}
		if (char_ok(89) == 0) {
				i = 89;
				set_state_continue(26);
				}
		if (char_ok(90) == 0) {
				i = 90;
				set_state_continue(26);
				}
		if (char_ok(91) == 0) {
				i = 91;
				set_state_continue(26);
				}
		if (char_ok(92) == 0) {
				i = 92;
				set_state_continue(26);
				}
		if (char_ok(93) == 0) {
				i = 93;
				set_state_continue(26);
				}
		if (char_ok(94) == 0) {
				i = 94;
				set_state_continue(26);
				}
		if (char_ok(95) == 0) {
				i = 95;
				set_state_continue(26);
				}
		if (char_ok(96) == 0) {
				i = 96;
				set_state_continue(26);
				}
		if (char_ok(97) == 0) {
				i = 97;
				set_state_continue(26);
				}
		if (char_ok(98) == 0) {
				i = 98;
				set_state_continue(26);
				}
		if (char_ok(99) == 0) {
				i = 99;
				set_state_continue(26);
				}
		if (char_ok(100) == 0) {
				i = 100;
				set_state_continue(26);
				}
		if (char_ok(101) == 0) {
				i = 101;
				set_state_continue(26);
				}
		if (char_ok(102) == 0) {
				i = 102;
				set_state_continue(26);
				}
		if (char_ok(103) == 0) {
				i = 103;
				set_state_continue(26);
				}
		if (char_ok(104) == 0) {
				i = 104;
				set_state_continue(26);
				}
		if (char_ok(105) == 0) {
				i = 105;
				set_state_continue(26);
				}
		if (char_ok(106) == 0) {
				i = 106;
				set_state_continue(26);
				}
		if (char_ok(107) == 0) {
				i = 107;
				set_state_continue(26);
				}
		if (char_ok(108) == 0) {
				i = 108;
				set_state_continue(26);
				}
		if (char_ok(109) == 0) {
				i = 109;
				set_state_continue(26);
				}
		if (char_ok(110) == 0) {
				i = 110;
				set_state_continue(26);
				}
		if (char_ok(111) == 0) {
				i = 111;
				set_state_continue(26);
				}
		if (char_ok(112) == 0) {
				i = 112;
				set_state_continue(26);
				}
		if (char_ok(113) == 0) {
				i = 113;
				set_state_continue(26);
				}
		if (char_ok(114) == 0) {
				i = 114;
				set_state_continue(26);
				}
		if (char_ok(115) == 0) {
				i = 115;
				set_state_continue(26);
				}
		if (char_ok(116) == 0) {
				i = 116;
				set_state_continue(26);
				}
		}
		
		if (choice == 2) {
				end();
				}
	}
	message_dialog("The altar is cold. The summoning of the demon has drained it completely.","");
	
break;

beginstate 23;
if (get_flag(13,8) == 0) {
		reset_dialog();
		add_dialog_str(0,"The temple is dominated by a black marble altar. It glows with a faint purple light. It doesn't seem to do anything, however. You could still kneel, if you want too.",0);
		add_dialog_choice(0,"Kneel");
		add_dialog_choice(1,"Leave");
		choice = run_dialog(0);
		
			if (choice == 1) {
					message_dialog("You kneel and stay in that position for five minutes or so. Nothing happens. You keep waiting. Still nothing happens. Eventually you leave. This altar doesn't do anything.","");
					set_flag(13,8,1);
					end();
					}
			if (choice == 2)
					end();
			}
		message_dialog("You already knelt once at this temple, but it didn't do anything. You would be wasting your time by trying again.","");
break;

beginstate 24;
reset_dialog();
	add_dialog_str(0,"This book is quite old and lies here for a long time. It was probably lying here since the crypt has been made. It is still in a readable condition, though. Do you want to read it?",0);
	add_dialog_choice(0,"Read the book");
	add_dialog_choice(1,"Leave it");
	choice = run_dialog(0);
	
	if (choice == 1) {
			message_dialog("The book is old and hard to read, but you manage. Apparently, the book describes Sir Dakrach's life.","You start to read the book. Its quite interesting.");
			message_dialog("Apparently, Sir Dakrach went to a foreign country in order of the Empire, where he conquered land. He acquired a sceptre. A drawing is drawn next to it. Its beautiful: laid in with ivory and gold.","You read on and come to a more interesting section. It describes where the sceptres are.");
			
			if (get_flag(13,2) == 1) {
					message_dialog("As you already got the sceptres, it isn't of much interest to you. You put the book back on the pedestal and leave.","");
					end();
					}
				message_dialog("It says here, that the sceptres lie in a hall to the north of where you are. In the hall there are two sceptres: a fake and a real one. It says here it was done like that to confuse adventurers. Adventurers like you.","");
				message_dialog("Eventually you stop reading and put the book back. It doesn't contain more information of interest to you.","");
			}
break;

beginstate 25;	
		place_monster(11,38,138,0);
		put_boom_on_char(i,2,0);
		set_character_facing(i,4);
		run_animation_sound(54);
		run_animation();
		
		i = i + 1;
		
		place_monster(9,38,138,0);
		put_boom_on_char(i,2,0);
		set_character_facing(i,4);
		run_animation_sound(54);
		run_animation();
		
		set_flag(275,1,i);

		text_bubble_on_char(0,"");
		text_bubble_on_char(3,"Oh no!");
		force_instant_terrain_redraw();
		pause(15);

		text_bubble_on_char(3,"");
		text_bubble_on_char(1,"Stupid traps.");
		force_instant_terrain_redraw();
		pause(15);

		text_bubble_on_char(1,"");
		relocate_character(0,10,40);
		relocate_character(1,10,41);
		relocate_character(2,10,42);
		relocate_character(3,10,43);
		relocate_character(4,10,44);
		relocate_character(5,11,44);
		force_instant_terrain_redraw();
		pause(15);
		
		end();
break;

beginstate 26;
		place_monster(15,3,60,0);
		put_boom_on_char(i,5,0);
		set_character_facing(i,4);
		run_animation_sound(61);
		set_flag(13,17,1);
break;